<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <script src="lib/vue_2.5.22.js"></script>
    <script src="lib/vue-router_3.0.2.js"></script>
    <title>Document</title>
</head>
<body>
    <div id="app">
        
        <router-link to='/user'>用户组件</router-link>
        <router-link to="/login">login组件</router-link>
        <router-view></router-view>
    </div>
</body>
<script>
    const User={
        template:`
            <div>
                用户组件
            </div>
             `
    };
    const Login={
        template:`
            <div>
                登录组件
            </div>
            `
    }
    // 1化路线图  创建路哟实例对象
    const router = new VueRouter({
        // 所有的路由规则
        routes:[
            {path:'/',redirect:'/user'},
            {path:'/user',component:User},
            {path:'/login',component:Login}
        ]
    })

    new Vue({
        el:'#app',
        router       
    })
</script>
</html>